<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<title>武汉理工大学出版社</title>
		<script src="js/jquery-3.2.1.min.js"></script>
		<script src="js/rem.js"></script>
		<link rel="stylesheet" href="css/reset.css">
		<link rel="stylesheet" href="css/page_div.css">
		<script src="js/v3.2.8/vue.global.prod.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/axios.min.js"></script>
		<link rel="stylesheet" href="css/style.css">
	</head>
	<body style="background-color: #fff;">
		<!-- 头部 -->
		<div id="header"></div>
		
		<div id="bootstrap"></div>
		
		<div class="sales_zone" id="app">
			<div class="sales_zone_nav">
				<div class="title">
					<div>
						<p class="p1">信息公开</p>
						<p class="p2">INFORMATION DISCLOSURE</p>
					</div>
				</div>
				<div class="nav_list">
					<ul>
						<li v-for="(item,index) in salesZoneList" @click="onSalesZone(index,item.name,item.code,item.children?item.children[0].code:'')" >
							<div class="one" :style="{'background': szCur==index?'#b3161d':''}">
								<div class="nav_list_left">
									<img v-if="szCur==index" class="img1" :src="szCur==index?'static/xzIcon1.png':''">
									<span :style="{'color': szCur==index?'#fff':''}">{{item.name}}</span>
								</div>
								<img class="img2" :src="szCur==index?'static/xzIcon2.png':'static/wxzIcon.png'"/>
							</div>
							<div class="tow" v-if="szCur==index" v-for="(listItem,listIndex) in item.children" @click.stop="onList(listIndex,listItem.code)">
								<img style="width: 0.3rem;" class="img2" :src="listIndexCur==listIndex?'static/dianIcon1.png':'static/dianIcon2.png'"/>
								<p :class="listIndexCur==listIndex?'towCur':''">{{listItem.name}}</p>
							</div>
						</li>
					</ul>
				</div>
			</div>
			
			<div class="sales_zone_cont">
				<!-- 类目标题 -->
				<div class="sales_zone_cont_title">
					<div class="sales_zone_cont_titles">
						<img src="static/titleIcon.png"/>
						<p>{{szName}}</p>
					</div>
					<img class="sales_zone_cont_title_back" src="static/titleBack.png">
				</div>
				<!-- 基本信息 -->
				<div class="" v-html="content" v-if="szCur==0 || curShow">
				</div>
				
				<!-- 管理服务 -->
				<div class="news" v-else>
					<div class="ban_list">
						<div class="ban_list_ul">
							<ul>
								<li v-for="(item,index) in publicInfoList"  @click="onDetails(item.content)">
									<p class="title">{{item.title}}</p>
									<p class="time">{{item.publishTime}}</p>
								</li>
							</ul>
						</div>
					</div>
				</div>
				<div v-cloak class="app" v-if="total>0&&publicInfoList!=''&&!curShow">
					<div v-show="total >= 1" class="pageContainer">
						<ul class="pagesInner">
<!--							<li class="page" @click="prevOrNext(-1)"><span aria-hidden="true">&lt;</span></li>-->
							<li class="page" v-for="(item, index) in pages" :key="index" :class="{actived: item == pageIndex}" @click="selectPage(item)">
								<span>{{item}}</span>
							</li>
<!--							<li class="page" @click="prevOrNext(1)"><span class="fa fa-chevron-right" aria-hidden="true">&gt;</span></li>-->
						</ul>
						共{{total}}页&nbsp;转到第&nbsp;
						<input type="text" v-model="goToPage" class="totalinput">
						&nbsp;页&nbsp;
						<button @click="handleGoToPage">GO</button>
					</div>
				</div>
			</div>
		
			<!-- 加载中 -->
			<div class="load_page" v-show="isLoadingShow">
				<div class="content">
					<div class="item">
						<i class="loader --1"></i>
					</div>
				</div>
			</div>
		</div>
		
		
		<!-- 底部 -->
		<div id="footer"></div>

	</body>
	<script>
		const App = {
			data() {
				return {
					szCur:0,
					listIndexCur:0,
					curShow:false,
					szName:'基本信息',
					salesZoneList:[],
					partyBuildCode:'DWJJ',
					pageIndex:1,
					pageSize:16,
					content: '',
					publicInfoList:[],
					goToPage: '',
					total:1,
					isLoadingShow:false
				}
			},
			computed: {
				pages: function () {
					// 每次最多显示5个页码
					var c = this.pageIndex
					var t = this.total
					var p = []
					for (var i = 1; i <= t; i++) {
						p.push(i)
					}
					var l = p.length
					if (l <= 5) { // 总页数<=5，显示全部页码
						return p
					} else if (l > 5 && c <= 4) { // 总页数>5 && 当前页面<=3
						return [1, 2, 3, 4, 5,'...', '尾页']
					} else if (l > 5&& c > 4 && c <= l - 3) { // 总页数 > 5 && 当前页面 > 3 && 当前页 < 总页数 - 3
						return [c - 3, c - 2, c - 1, c, c + 1,  '...', '尾页']
					} else { // 总页数 > 5 && 当前页面 > 3 && 当前页 > 总页数 - 3
						debugger
						return [ '首页',t - 3, t - 2, t - 1,t ]
					}
				},
			},
			mounted(){
				sessionStorage.setItem('href',window.location.href);
				this.isLoadingShow = true
				this.getPartyBuildClassify()
				this.getPartyBuild()
			},
			methods:{
				async getPartyBuildClassify() {
					let that = this;
					await axios({
						method: "get",
						url: "http://dbs.wutp.com.cn/CM-API/publicInfoApi/getPartyBuildClassify",
					}).then(function (res) {
						that.salesZoneList = res.data.data;
						that.isLoadingShow = false
					})
				},
				async getPartyBuild() {
					let that = this;
					const searchParam = {SEARCH_EQ_classify_code:this.partyBuildCode}
					const orderParam={order_no: false}
					await axios({
						method: "get",
						url: "http://dbs.wutp.com.cn/CM-API/publicInfoApi/getPartyBuild?pageNum=" + that.pageIndex + "&pageSize=" + that.pageSize,
						params: {searchParam: searchParam,orderParam:orderParam},
					}).then(function (res) {
						if (res.data.data.content.length>0) {
							for(var i=0;i<res.data.data.content.length;i++){
								if(res.data.data.content[i].publicInfoCode=='JBXX'){
									that.content = res.data.data.content[0].content;
								}else{
									that.publicInfoList = res.data.data.content;
									// 总条数除以10并向上取整得到总页数
									const total = res.data.data.total / that.pageSize;
									that.total = Math.ceil(total);
									// that.total = res.data.data.total;
									that.pageIndex = res.data.data.pageNum
									that.pageSize = res.data.data.pageSize;
								}
							}
						}else{
							that.content = ''
							that.publicInfoList = ''
						}
						that.isLoadingShow = false
					})
				},
				onSalesZone(e,n,code){
					this.isLoadingShow = true
					this.szCur = e;
					this.szName = n;
					this.curShow = false;
					this.pageIndex = 1
					this.pageSize = 10
					this.listIndexCur = 0
					if(code=='GLFW'){
						this.partyBuildCode = 'GLQD'
					}else if(code=='JBXX'){
						this.partyBuildCode = 'DWJJ'
					}else{
						this.partyBuildCode = code
					}
					this.getPartyBuild()
				},
				onList(e,code){
					this.isLoadingShow = true
					this.curShow = false;
					this.listIndexCur = e;
					this.pageIndex = 1
					this.pageSize = 10
					this.partyBuildCode = code
					this.getPartyBuild()
				},
				onDetails(content){
					this.curShow = true;
					this.content = content
				},
				prevOrNext: function(n) {
					this.isLoadingShow = true
					this.pageIndex += n
					this.pageIndex <= 1 ? this.pageIndex = 1 : this.pageIndex > this.total ? this.pageIndex = this.total : null
					this.getPartyBuild();
				},
				selectPage: function(n) {
					if(n=='尾页'){
						n = this.total
					}
					if(n=='首页'){
						n = 1
					}
					this.isLoadingShow = true
					if (n === this.pageIndex) return
					if (typeof n === 'string') return
					this.pageIndex = n;
					this.getPartyBuild();
				},
				handleGoToPage: function() {
					this.isLoadingShow = true
					this.pageIndex = this.goToPage <= 1 ? 1 : this.goToPage - 0 >= this.total - 0 ? this.total :
							this.goToPage
					this.goToPage = this.pageIndex;
					this.getPartyBuild();
				},
			}
		};
		Vue.createApp(App).mount('#app');
		
	</script>

	<style>
		.sales_zone{
			display: flex;
			margin: 0 3rem;
		}
		.sales_zone_nav{
			margin-right: 0.3rem;
		}
		.sales_zone_nav .title{
			width: 2.7rem;
			height: 0.88rem;
			background-image: url("img/back2.png");
			background-size: cover;
			background-repeat: no-repeat;
			background-position: center;
			display: flex;
			align-items: center;
			padding-left: 0.3rem;
			margin: 0 0.01rem;
		}
		.sales_zone_nav .title .p1{
			font-size: 0.24rem;
			color: #fff;
			font-weight: 600;
			letter-spacing: 0.01rem;
			margin-bottom: 0.1rem;
		}
		.sales_zone_nav .title .p2{
			font-size: 0.13rem;
			color: #fff;
			font-weight: 600;
			line-height: 0.12rem;
		}
		.nav_list{
			
		}
		
		.nav_list ul li .one{
			height: 0.7rem;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 0.3rem;
			border: 0.01rem solid #eee;
			border-top: none;
			cursor: pointer;
		}
		.nav_list ul li .tow{
			height: 0.5rem;
			display: flex;
			align-items: center;
			padding: 0 0.5rem;
			background-color: #f3f3f3;
			border-top: none;
			cursor: pointer;
		}
		
		.nav_list ul li .tow p{
			font-size: 0.16rem;
			color: #333;
			margin-left: 0.06rem;
		}
		.nav_list ul li .tow .towCur{
			 color: #b3161d;
			 font-size: 0.17rem;
			 font-weight: 600;
		}
		
		
		.nav_list_left{
			display: flex;
			align-items: center;
		}
		.nav_list ul li .img1{
			width: 0.14rem;
			margin-right:0.2rem;
		}
		.nav_list ul li .img2{
			width: 0.07rem;
			margin-left: 0.12rem;
		}
		.nav_list ul li span{
			font-size: 0.17rem;
		}
		
		.sales_zone_cont{
			flex: 1;
			margin-top: 0.2rem;
		}
		.sales_zone_cont_title{
			margin-bottom: 0.2rem;
		}
		.sales_zone_cont_titles{
			display: flex;
			align-items: center;
			margin-bottom: 0.3rem;
		}
		.sales_zone_cont_titles p{
			font-size: 0.3rem;
			font-weight: 600;
		}
		.sales_zone_cont_titles img{
			width: 0.1rem;
			margin-right: 0.1rem;
		}
		.sales_zone_cont_title_back{
			width: 100%;
			height: 0.1rem;
		}
		
		.news .ban_list_ul ul li{
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0.12rem 0;
			cursor: pointer;
		}
		.news .ban_list_ul ul li .title{
			width: 80%;
			font-size: 0.16rem;
			color: #333;
			background: url(static/icon3.png) no-repeat;
			background-size:0.22rem;
			background-position: left;
			padding-left: 0.22rem;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}
		.news .ban_list_ul ul li .time{
			font-size: 0.16rem;
			color: #666;
		}
	</style>
</html>
